package 代码记录.指定公司代码练习记录.西安.分值100分未做;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

/**
 * @author zx
 * @create 2023-07-08 17:28
 * 人家的代码报异常，我也做不出来，但这道题确实不错(这道题别看了！！)
 */
public class 热点网络统计 {
    private static final Map<String, Integer> map = new HashMap<>();
    public static void main(String[] args) {
        try (Scanner s = new Scanner(System.in)) {
            while (s.hasNext()) {
                solveMethod(s.nextLine());
            }
        }
    }

    private static void solveMethod(String line) {
        map.put(line, line.length() > 2 ? map.getOrDefault(line, 0) + 1 : map.getOrDefault(line, 0));
        int n = Integer.parseInt(line);
        List<Map.Entry<String, Integer>> list = map.entrySet()
                .stream()
                .sorted((e1, e2) -> e2.getValue().compareTo(e1.getValue()))
                .collect(Collectors.toList());
        for (int i = 0; i < n; ++i) {
            System.out.print(list.get(i).getKey());
            if (i != n - 1)
                System.out.print(",");
        }
        System.out.println();
    }
}
